import request from "@/utils/request"

/**
 * 添加订单
 * @param orderRequestVO 订单信息
 * @returns 添加结果
 */
export const addOrderAPI = (orderRequestVO) => {
  return request({
    url: '/order/add',
    method: 'post',
    data: orderRequestVO
  })
}

/**
 * 删除订单
 * @param orderId 订单ID
 * @returns 删除结果
 */
export const deleteOrderAPI = (orderId) => {
  return request({
    url: `/order/delete/${orderId}`,
    method: 'delete'
  })
}

/**
 * 修改订单状态
 * @param id 订单ID
 * @param orderState 订单状态
 * @returns 修改结果
 */
export const updateOrderStateAPI = (id, orderState) => {
  return request({
    url: `/order/upState/${id}/${orderState}`,
    method: 'put'
  })
}

/**
 * 获取订单详情（包含订单信息和订单明细）
 * @param orderId 订单ID
 * @returns 订单详情
 */
export const getOrderDetailAPI = (orderId) => {
  return request({
    url: `/order/detail/${orderId}`,
    method: 'get'
  })
}

/**
 * 获取订单信息（仅订单信息）
 * @param orderId 订单ID
 * @returns 订单信息
 */
export const getOrderAPI = (orderId) => {
  return request({
    url: `/order/get/${orderId}`,
    method: 'get'
  })
}

/**
 * 获取当前用户的所有订单
 * @returns 订单列表
 */
export const getOrderListAPI = () => {
  return request({
    url: '/order/list',
    method: 'get'
  })
}

/**
 * 更新订单地址
 * @param orderId 订单ID
 * @param addressId 地址ID
 * @returns 更新结果
 */
export const updateOrderAddressAPI = (orderId, addressId) => {
  return request({
    url: `/order/updateAddress/${orderId}`,
    method: 'put',
    params: { addressId }
  })
}